<?php

include("sys_config.php");

if (!$con) {
    die("<h1>Conexão Falhou</h1>");
}


//Limpador de BD
mysql_query("drop table pacientes");
mysql_query("drop table consulta");
mysql_query("drop table funcionarios");
mysql_query("drop table medicos");
mysql_query("drop table user");

mysql_query("
        CREATE TABLE if NOT EXISTS funcionarios (
            id INT PRIMARY KEY AUTO_INCREMENT,
            Nome varchar(80) NOT NULL,
            Sobrenome varchar(80) NOT NULL,
            RG int UNIQUE KEY NOT NULL,
            CPF int UNIQUE KEY NOT NULL,
            Telefone1 int NOT NULL,
            Telefone2 int,
            Email varchar(15) NOT NULL
            );
        ") or die (mysql_error());

mysql_query(" 
        CREATE TABLE if NOT EXISTS user (
            id INT PRIMARY KEY AUTO_INCREMENT,
            usuario VARCHAR(100) NOT NULL,
            senha VARCHAR(100) NOT NULL,
            nome VARCHAR(100) NOT NULL,
            nivel VARCHAR(100) NOT NULL
            );
        ") or die(mysql_error());

mysql_query("
        CREATE TABLE IF NOT EXISTS medicos (
            Nome varchar(80) NOT NULL,
            Sobrenome varchar(80) NOT NULL,
            RG int UNIQUE KEY NOT NULL,funcionarios
            CPF int UNIQUE KEY NOT NULL,
            Telefone1 int NOT NULL,
            Telefone2 int,
            Email varchar(15) NOT NULL,
            Plano_de_Saude varchar(80) NOT NULL,
            CRM int UNIQUE KEY NOT NULL,
            Especialidade varchar(80) NOT NULL,
            id INT PRIMARY KEY AUTO_INCREMENT NOT NULL
        )") or die(mysql_error());

mysql_query("
        CREATE TABLE IF NOT EXISTS pacientes (
            Nome varchar(80) NOT NULL,
            Sobrenome varchar(80) NOT NULL,
            RG int UNIQUE KEY NOT NULL,
            CPF int UNIQUE KEY NOT NULL,
            Alergias varchar(80) NOT NULL,
            Deficiencias varchar(80) NOT NULL,
            Telefone1 int NOT NULL,
            Telefone2 int NOT NULL,
            Plano_de_Saude varchar(80) NOT NULL,
            Email varchar(80) NOT NULL,
            id INT PRIMARY KEY AUTO_INCREMENT NOT NULL
        )") or die(mysql_error());

mysql_query("
        CREATE TABLE IF NOT EXISTS consulta (
            Medico int NOT NULL,
            Paciente int NOT NULL,
            Especialidade varchar (80) NOT NULL,
            Data date NOT NULL,
            Hora time NOT NULL,
            id int PRIMARY KEY NOT NULL AUTO_INCREMENT,
            Consulta_Anterior int NOT NULL
        )") or die(mysql_error());

mysql_query("INSERT INTO user (usuario, senha, nome, nivel) VALUES ('root', 'root', 'root', 'Administrador')") or die(mysql_error());

mysql_close();





/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

